﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AIproject
{
    class Model : Dictionary<string, bool>
    {

        /// <summary>
        /// random assignment of values
        /// </summary>
        public void randomAssignment()
        {
            Random random = new Random();
            string stringTemp; 
            List<string> list = this.Keys.ToList<string>();

            foreach (string str in list)
            {
                if (random.NextDouble() < 0.5)
                {
                    stringTemp = str;
                    this.Remove(str);
                    this.Add(stringTemp, true);
                }
                else
                {
                    stringTemp = str;
                    this.Remove(str);
                    this.Add(stringTemp, false);
                }
            }//end foreach
        }

        //flip the symbol value
        public void flip(string symbolName)
        {
            bool tvalue;
            this.TryGetValue(symbolName, out tvalue);
            this.Remove(symbolName);
            this.Add(symbolName, !(tvalue));
        }
    }
}
